package com.v5ent.mongo4j.service;

import com.v5ent.mongo4j.dao.UserDao;
import com.v5ent.mongo4j.entity.User;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class UserService {
    @Resource
    private UserDao userDao;

    public List<User> findAll(){
        return userDao.findAll();
    }

    public User findById(Long id){
        return userDao.findById(id).get();
    }

    public void  update(User user){
        userDao.save(user);
    }

    public void deleteById(Long id){
        userDao.deleteById(id);
    }
}
